<?php
	session_start();
	$path=$_SERVER["DOCUMENT_ROOT"]."/Clase/php/FORO/clases/";
	if (!isset($_SESSION["USUSARI"])) header ("Location: ../index.php");
	require_once ($path."Usuaris.php");
	require_once ($path."Imatges.php");
	$usuari=new Usuaris();
	$img=new Imatges();
	if (isset($_REQUEST["Aceptar"])){
		$usuari->updateUsuari();
		$img->addFoto($_REQUEST["foto"],$usuari->obtenirID());
	}
?>
<html>
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title><?php echo $usr["nom"];?></title>
		<script type="text/javascript" src="../SCRIPTS/javascript.js"></script>
		<link rel="stylesheet" type="text/css" href="../CSS/styles.css" />
	</head>
	<body>
	<div class="contenedor">
	<?php include_once("../clases/menu2.php");?>
	<?php foreach ($usuari->setUsuari() as $usr){?>
		<form action="edit.php" metodh="post" name="registre">
        <div class="resultat" style="margin-top:30px;height:25px;">
            <div class="resultatItem">Nom: <input type="text" name="nom" value="<?php echo $usr["nom"]?>" required></div>
            <div class="resultatItem" style="margin-left: 30%;">Cognoms: <input type="text" name="cognoms" value="<?php echo $usr["cnom1"]." ".$usr["cnom2"]?>" required></div>
        </div>
        <div class="resultat" style="margin-top:30px;height:25px;">
            <div class="resultatItem">Email: <input type="email" name="email1" value="<?php echo $usr["email"]?>" required></div>
            <div class="resultatItem" style="margin-left: 30%;">Verificacio d'email: <input type="email" name="email2" value="<?php echo $usr["email"]?>" required></div>
        </div>
        <div class="resultat" style="margin-top:30px;height:25px;">    
            <div class="resultatItem">Contrasenya: <input type="password" name="passwd1" value="<?php echo $usr["passwd"]?>" required></div>
            <div class="resultatItem" style="margin-left: 30%;">Verificacio de contrasenya: <input type="password" name="passwd2" value="<?php echo $usr["passwd"]?>" required></div>
        </div>
        <div class="resultat" style="margin-top:30px;height:25px;">
        	<?php $img->setRuta($usr["id"])?>
            <div class="resultatItem">Foto: <input type="file" name="image" value="<?php echo $img->getRuta()?>"></div>
            <input type="hidden" name="id" value="<?php echo $usr["id"]?>">
            <div class="resultatItem" style="margin-left: 30%;"><input type="submit" name="Aceptar" value="Aceptar" onClick="validarUsuari()"></div>
        </div>
        </form>  
        <?php }?>
	</div>
	</body>
</html>